import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { cardContentDefaultProps } from './defaultProps';
import type { CardContentOptions } from './type';

export interface CardContentProps extends CardContentOptions, HTMLAttributes<HTMLDivElement> {}

const CardContent: FC<CardContentProps> = (props) => {
  const { className, extra, aligned, children, forwardedRef, ...cardContentProps } = props;

  return createElement(
    'div',
    {
      ref: forwardedRef,
      className: classNames({ extra }, aligned, { aligned }, 'content', className),
      ...cardContentProps,
    },
    children,
  );
};

CardContent.displayName = 'CardContent';
CardContent.defaultProps = cardContentDefaultProps;

export default CardContent;
